/*    */ package com.zimbra.cs.service.admin;
/*    */ 
/*    */ import com.zimbra.common.account.Key.CosBy;
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.common.soap.Element;
/*    */ import com.zimbra.common.soap.SoapProtocol;
/*    */ import com.zimbra.cs.account.AccountServiceException;
/*    */ import com.zimbra.cs.account.Entry;
/*    */ import com.zimbra.cs.account.Provisioning;
/*    */ import com.zimbra.cs.account.accesscontrol.AdminRight;
/*    */ import com.zimbra.cs.mailbox.RetentionPolicyManager;
/*    */ import com.zimbra.soap.JaxbUtil;
/*    */ import com.zimbra.soap.ZimbraSoapContext;
/*    */ import com.zimbra.soap.admin.message.DeleteSystemRetentionPolicyRequest;
/*    */ import com.zimbra.soap.admin.message.DeleteSystemRetentionPolicyResponse;
/*    */ import com.zimbra.soap.admin.type.CosSelector;
/*    */ import com.zimbra.soap.admin.type.CosSelector.CosBy;
/*    */ import com.zimbra.soap.mail.type.Policy;
/*    */ import java.util.List;
/*    */ import java.util.Map;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class DeleteSystemRetentionPolicy
/*    */   extends AdminDocumentHandler
/*    */ {
/*    */   public Element handle(Element request, Map<String, Object> context)
/*    */     throws ServiceException
/*    */   {
/* 43 */     ZimbraSoapContext zsc = getZimbraSoapContext(context);
/*    */     
/* 45 */     DeleteSystemRetentionPolicyRequest req = (DeleteSystemRetentionPolicyRequest)JaxbUtil.elementToJaxb(request);
/* 46 */     Provisioning prov = Provisioning.getInstance();
/*    */     
/* 48 */     Entry entry = prov.getConfig();
/*    */     
/* 50 */     CosSelector cosSelector = req.getCos();
/* 51 */     if (cosSelector != null) {
/* 52 */       entry = prov.get(Key.CosBy.fromString(cosSelector.getBy().name()), cosSelector.getKey());
/* 53 */       if (entry == null) {
/* 54 */         throw AccountServiceException.NO_SUCH_COS(cosSelector.getKey());
/*    */       }
/*    */     }
/* 57 */     CreateSystemRetentionPolicy.checkSetRight(entry, zsc, context, this);
/*    */     
/*    */ 
/* 60 */     Policy policy = req.getPolicy();
/* 61 */     if (policy == null) {
/* 62 */       throw ServiceException.INVALID_REQUEST("policy not specified", null);
/*    */     }
/* 64 */     String id = policy.getId();
/* 65 */     if (id == null) {
/* 66 */       throw ServiceException.INVALID_REQUEST("Policy id not specified", null);
/*    */     }
/* 68 */     boolean success = RetentionPolicyManager.getInstance().deleteSystemPolicy(entry, id);
/* 69 */     if (!success) {
/* 70 */       throw ServiceException.INVALID_REQUEST("Could not find policy with id " + id, null);
/*    */     }
/* 72 */     DeleteSystemRetentionPolicyResponse res = new DeleteSystemRetentionPolicyResponse();
/* 73 */     return JaxbUtil.jaxbToElement(res, zsc.getResponseProtocol().getFactory());
/*    */   }
/*    */   
/*    */   public void docRights(List<AdminRight> relatedRights, List<String> notes)
/*    */   {
/* 78 */     notes.add("Need set attr right on attribute zimbraMailPurgeSystemPolicy");
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/service/admin/DeleteSystemRetentionPolicy.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */